include(FetchContent)

# 描述如何获取 Catch2
FetchContent_Declare(
    catch2 # 建议使用全小写
    GIT_REPOSITORY https://github.com/catchorg/Catch2.git
    GIT_TAG v3.0.0-preview3)

# 一条龙地下载、构建 Catch2
FetchContent_MakeAvailable(catch2)

macro(MG_add_test TEST_NAME)
    add_executable(${TEST_NAME} ${ARGN})
    add_test(NAME MG.${TEST_NAME} COMMAND ${TEST_NAME})
    target_link_libraries(${TEST_NAME} PRIVATE Catch2::Catch2WithMain)
    target_link_libraries(${TEST_NAME} PRIVATE lapack)
    target_link_libraries(${TEST_NAME} PRIVATE jsoncpp)
endmacro()

MG_add_test(test_operator test_operator.cpp)
MG_add_test(test_grid test_grid.cpp)
MG_add_test(test_convergence test_convergence.cpp)
MG_add_test(test_functions test_functions.cpp)
MG_add_test(test_all test_all.cpp)